package com.ctsi.framework.elementui.support;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

public class GroupOption implements Serializable {

    private String label;

    private List<Option> options = new ArrayList<>();

    private GroupOption() {
    }

    private GroupOption(String label){
        this.label = label;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public List<Option> getOptions() {
        return options;
    }

    public void setOptions(List<Option> options) {
        this.options = options;
    }

    public <T> GroupOption addOptions(T t , Function<T,List<Option>> func){
        this.options.addAll(func.apply(t));
        return this;
    }

    public <T> GroupOption addOption(T t , Function<T,Option> func){
        this.options.add(func.apply(t));
        return this;
    }

    public static GroupOption init(String label){
        return new GroupOption(label);
    }
}
